package com.testingedu.action.front;

import com.testingedu.action.background.RequestContext;
import com.testingedu.jdbcDao.TTrainInfoDao;
import com.testingedu.model.TCategory;
import com.testingedu.model.TTrainInfo;

public class TTrainInfoAction extends RequestContext{

	private static final long serialVersionUID = 7932071761324806829L;
	private TTrainInfo tTrainInfo;
	public void settTrainInfo(TTrainInfo tTrainInfo) {
		this.tTrainInfo = tTrainInfo;
	}

	private static TTrainInfoDao tTrainInfoDao = new TTrainInfoDao();
	
	public void list_() throws Exception {
		createQueryResult();
		String categoryName = request.getParameter("category_name");
		TCategory tCategory = new TCategory();
		tCategory.setName(categoryName);
		if(tTrainInfo == null) {
			tTrainInfo = new TTrainInfo();
		}
		tTrainInfo.settCategory(tCategory);
		tTrainInfoDao.list(queryResult, tTrainInfo);
		request.setAttribute("queryResult", queryResult);
		request.getRequestDispatcher("/news/list.jsp").forward(request, response);
	}
	
	public void info_() throws Exception {
		tTrainInfo = tTrainInfoDao.info(tTrainInfo.getId());
		request.setAttribute("tTrainInfo", tTrainInfo);
		request.getRequestDispatcher("/news/info.jsp").forward(request, response);
	}
}
